package com.hzdl.car.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Random;

public class Common {
    private static SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd_HHmmss_SSS");
    private static Random random=new Random();

    public static  boolean isEmpty(String s){
        if(s==null)
        {
            return true;
        }
        if("".equals(s)){
            return true;
        }
        return false;
    }

    public static void getTreeNodeMenu(List<TreeNode> treeNodes, Integer id , List<TreeNode> treeNodes2) {
        // 把数转换成有乘级关系的数据
        for (TreeNode t1 : treeNodes) {
            if (t1.getpId() == id) { // 判断是一级菜单
                treeNodes2.add(t1);
            }
            for (TreeNode t2 : treeNodes) {
                // 查询子菜单
                if (t1.getId() == t2.getpId()) {
                    t1.getChildren().add(t2);
                }
            }
        }
    }

    public static String createRandomStringUseTime(String preffx) {

        return preffx+"_"+sdf.format(new Date())+"_"+(random.nextInt(90000)+10000);
    }

}
